﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Huirui.Cavan.Domain.MainBoundedContext.ReportModule;
using Spring.Data.Generic;

namespace Huirui.Cavan.Infrastructure.Data.MainBoundedContext.StockModule
{
    public class StockBySalesReportMapper : IRowMapper<StockBySalesReport>
    {
        #region IRowMapper<StockBySalesReportMapper> 成员

        public StockBySalesReport MapRow(System.Data.IDataReader reader, int rowNum)
        {
            StockBySalesReport report = new StockBySalesReport();
            report.ReturnAmount = 0;
            report.ReturnNumber = 0;
            report.Code = Convert.ToString(reader["Code"]);
            report.SalesDate = Convert.ToDateTime(reader["SalesDate"]).ToShortDateString();
            report.Name = Convert.ToString(reader["Name"]);
            report.Number = Convert.ToDecimal(reader["Number"]);
            report.SalesCode = Convert.ToString(reader["SalesCode"]);
            report.UnitCost = Convert.ToDecimal(reader["UnitCost"]);
            report.Amount = report.Number * report.UnitCost;

            return report;
        }

        #endregion
    }
}
